<%-- 
    Document   : conversor
    Created on : 03/12/2011, 09:48:49
    Author     : Gledson
--%>

<%@page import="sun.font.Script"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="cmstyle.css">
        <title>Conversão de Largura de Banda</title>
    </head>
    <body>

         <ul class="navbar">
        <li><a href="index.jsp">Home page</a>         
        <li><a href="Paginas/equipe.jsp">Quem somos?</a>
        <li><a href="Paginas/volume.jsp">Volume</a>
        <li><a href="Paginas/moeda.jsp">Moeda</a>
        <li><a href="Paginas/Aceleracao.jsp">Aceleração </a>
        <li><a href="Paginas/corrente.jsp">Corrente Eletrica </a> 
        <li><a href="Paginas/Potencia.jsp">Potência</a>    
        <li><a href="Paginas/ConverterPrincipal.jsp"> Velocidade </a>    
        <li><a href="Paginas/Comprimento.jsp"> Comprimento </a>
        <li><a href="Paginas/ResistenciaEletrica.jsp"> Resistencia Eletrica </a>
        <li><a href="Paginas/CoversorDeMassa.jsp"> Massa </a>
        <li><a href="Paginas/temperatura.jsp"> Temperatura </a>  
        <li><a href="Paginas/largura_banda.jsp"> Largura de Banda </a>
        <li><a href="Paginas/dados.jsp"> Armazenamento de Dados </a>
        </ul>

        <%
            Double valor = Double.parseDouble(request.getParameter("valor"));
            String tipo = request.getParameter("cbTipo");
            Double bits = 0.0;
            Double Kbits = 0.0;
            Double Mbits = 0.0;
            Double Gbits = 0.0;
            Double Tbits = 0.0;
            Double bytes = 0.0;
            Double Kbyte = 0.0;
            Double Mbyte = 0.0;




            if (tipo.equals("Bits/s")) {
                bits = valor;
                Kbits = valor / 1000;
                Mbits = valor / 1000000;
                Gbits = valor * Math.pow(10, -9);
                Tbits = valor * Math.pow(10, -12);
                bytes = valor / 8;
                Kbyte = valor *= Math.pow(10, -3);
                Mbyte = valor / 8000000;
            } else if (tipo.equals("KBits/s")) {
                bits = valor * 1000;
                Kbits = valor;
                Mbits = valor / 1000;
                Gbits = valor / 1000000;
                Tbits = valor / 100000000;
                bytes = valor * 125;
                Kbyte = valor * 0.125;
                Mbyte = valor * 0.000125;
            } else if (tipo.equals("MBits/s")) {
                bits = valor * 1000000;;
                Kbits = valor * 1000;;
                Mbits = valor;
                Gbits = valor / 1000;
                Tbits = valor / 1000000;
                bytes = valor * 125000;
                Kbyte = valor * 125;
                Mbyte = valor * 0.125;
            }
        %>

        <table border="1" align="center" width =" 60%">
            <thead>
                <tr>
                    <th colspan="3"><h1>Valor Convertido</h1></th>

    </tr>
</thead>
<tbody>
    <tr>
        <td align="center"><h3>Bits.:</h3></td>
        <td align="center" colspan="2"><h3><%= bits%></h3></td>
    </tr>       
    <tr>
        <td align="center"><h3>KBits/s.:</h3></td>
        <td align="center" colspan="2"><h3><%= Kbits%></h3></td>
    </tr>
    <tr>
        <td align="center"><h3>MBits/s.:</h3></td>
        <td align="center" colspan="2"><h3><%= Mbits%></h3></td>
    </tr>
    <tr>
        <td align="center"><h3>GBits/s.:</h3></td>
        <td align="center" colspan="2"><h3><%= Gbits%></h3></td>
    </tr>
    <tr>
        <td align="center"><h3>TBits/s.:</h3></td>
        <td align="center" colspan="2"><h3><%= Tbits%></h3></td>
    </tr>
    <tr>
        <td align="center"><h3>Bytes/s.:</h3></td>
        <td align="center" colspan="2"><h3><%= bytes%></h3></td>
    </tr>
    <tr>
        <td align="center"><h3>MBytes/s.:</h3></td>                                          
        <td align="center" colspan="2"><h3><%= Mbyte%></h3></td>                                          
    </tr>

</tbody>
</table>
    
    <center><a href="largura_banda.jsp">Página anterior</a></center>

</body>
</html>
